package com.health.adapter;

import com.health.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 主菜单布局adapter【体检】
 */
public class MainMenuGridAdapter_Tj extends BaseAdapter {
	private int[] imgs;
	private String[] names;
	private int[] colors;
	private Context mContext;
	// 0 "个人档案",
	// 1 "健康体检",
	// 2 "重点人群",
	// 3 "综合统计",
	// 4 "打印条码",
	// 5 "打印体检回执"
	// 6 "拍取照片"

	public MainMenuGridAdapter_Tj(Context mContext) {
		this.mContext = mContext;

		imgs = new int[] { R.drawable.self_record, R.drawable.self_tj, R.drawable.main_zdrq,
				R.drawable.self_print_tm, R.drawable.self_pz, R.drawable.self_lbxd };// ,R.drawable.main_grda
		// "综合统计",R.drawable.main_zhtj, , 0xff67A6CB   "健康教育", 0xffCFAE6F, R.drawable.self_jkjy,  "打印条码", 0xff46B9C7,,R.drawable.self_print
		names = new String[] { "个人档案", "健康体检", "重点人群",  "体检报告", "拍取照片", "设备测量" };// "打印体检回执",
		colors = new int[] { 0xff4680C7, 0xff4680C7,  0xff71B57C, 0xffE06060, 0xffCFAE6F, 0xff71B57C };// ,
																													// 0xff71B57C
																													// 使用PicPick吸取色值后获取html的颜色字符（E06060
		// ），前面加上ff（ffE06060）
	}

	@Override
	public int getCount() {
		return imgs.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(R.layout.main_menu_griditem, null);
			vh = new ViewHolder();
			int drawableID = imgs[position];
			String name = names[position];
			int color = colors[position];
			findView(vh, convertView, drawableID, name, color,position);
			convertView.setTag(R.id.TAG_VIEWHOLDER, vh);
		} else{
			vh = (ViewHolder) convertView.getTag(R.id.TAG_VIEWHOLDER);
		}
		setData(vh, convertView, position);

		return convertView;
	}

	/**
	 * 赋值
	 * 
	 * @param h
	 * @param v
	 * @param position
	 * @author 王婷婷
	 * @date 2015年12月3日 上午10:24:28
	 */
	private void setData(ViewHolder h, View v, int position) {
	}

	private void findView(ViewHolder h, View v, int drawableID, String name, int color,int position) {
		h.img = (ImageView) v.findViewById(R.id.norm_img);
		h.nameText = (TextView) v.findViewById(R.id.norm_name);

		h.img.setImageResource(drawableID);
		h.nameText.setText(name);
		h.nameText.setTextColor(color);
		if(position==4){
			h.nameText.setTextColor(0xFFcccccc);
//			v.setBackgroundColor(0x649C9C9C);
		}
		
	}

	private static class ViewHolder {
		ImageView img;
		TextView nameText;
	}

}
